<?php
/* SVN FILE: $Id: form_controller.php 107 2007-04-14 17:07:09Z Andy $ */

/**
 * Short description for file.php.
 *
 * Long description for file
 *
 * PHP versions 4 and 5
 *
 * Copyright (c), Andy Dawson
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright    Copyright (c) 2007, Andy Dawson
 * @package      noswad
 * @subpackage   noswad.app.plugins.pagination.controllers
 * @since        Noswad site version 3
 * @todo         TODO Edit this block
 * @version      $Revision: 107 $
 * @created      26/01/2007
 * @modifiedby   $LastChangedBy$
 * @lastmodified $Date: 2007-04-14 19:07:09 +0200 (sáb, 14 abr 2007) $
 * @license      http://www.opensource.org/licenses/mit-license.php The MIT License
 */

/**
 * Short description for Class
 *
 * Long descrption of Class
 */

/**
 * Description for var
 *
 * @var type
 * @access public/private/protected
 */

/**
 * Description for method
 *
 * @param type $name description
 * @return type description
 */
 class FormController extends PaginationAppController {
	var $name = 'Form'; // required for PHP4 installs

	function index() {
		$this->_addFlash("Please note this only works with Ajax. To work without ajax you could use forms submitting by GET.");
	}

	function search() {
		if ($this->data['Form']['search']) {
			$match = $this->data['Form']['search'];
			$criteria = array("Title.title"=>"like %$match%");
		} else {
			$criteria = array();
		}
		list($order,$limit,$page) = $this->Pagination->init($criteria,null,array('ajaxDivUpdate'=>"example",'ajaxFormId'=>'searchForm'));
		$this->data = $this->{$this->modelClass}->findAll($criteria, null, $order, $limit, $page);
	}

	function _defineContextMenus() {
		return array (
			'Actions' => array (
				'data' => array (
					array (
						'title' => 'search home',
						'url' => "/{$this->plugin}/{$this->name}/"
					)
				)
			)
		);
	}
}
?>